Push latest changes to opensource. git-svn-id: http://google-cache-invalidation-api.googlecode.com/svn/trunk@297 1cc9d426-c294-39be-ba72-c0199ca0f247 
diff --git a/src/java/com/google/ipc/invalidation/common/BuildConstants.java b/src/java/com/google/ipc/invalidation/common/BuildConstants.java new file mode 100644 index 0000000..2ce3d6f --- /dev/null +++ b/src/java/com/google/ipc/invalidation/common/BuildConstants.java 
@@ -0,0 +1,37 @@ +/* + * Copyright 2011 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * Copyright 2013 Google Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http: *www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS-IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.ipc.invalidation.common; + +/** Build constant definitions. */ +class BuildConstants { + static final int BUILD_DATESTAMP = 20130403; +} 
diff --git a/src/java/com/google/ipc/invalidation/common/CommonInvalidationConstants2.java b/src/java/com/google/ipc/invalidation/common/CommonInvalidationConstants2.java index 4750dd3..4cca6ec 100644 --- a/src/java/com/google/ipc/invalidation/common/CommonInvalidationConstants2.java +++ b/src/java/com/google/ipc/invalidation/common/CommonInvalidationConstants2.java 
@@ -32,8 +32,11 @@  /** Major version of the client library. */  public static final int CLIENT_MAJOR_VERSION = 3;   - /** Minor version of the client library. */ - public static final int CLIENT_MINOR_VERSION = 3; + /** + * Minor version of the client library, defined to be equal to the datestamp of the build + * (e.g. 20130401). + */ + public static final int CLIENT_MINOR_VERSION = BuildConstants.BUILD_DATESTAMP;    /** Major version of the protocol between the client and the server. */  public static final int PROTOCOL_MAJOR_VERSION = 3; 
diff --git a/src/java/com/google/ipc/invalidation/examples/android2/ExampleListener.java b/src/java/com/google/ipc/invalidation/examples/android2/ExampleListener.java index 7fd8521..98c3b3c 100644 --- a/src/java/com/google/ipc/invalidation/examples/android2/ExampleListener.java +++ b/src/java/com/google/ipc/invalidation/examples/android2/ExampleListener.java 
@@ -118,8 +118,8 @@  Log.i(TAG, "invalidate: " + invalidation);    // Do real work here based upon the invalidation - MainActivity.State.setVersion(invalidation.getObjectId(), - "Version from invalidate: " + invalidation.getVersion()); + MainActivity.State.setVersion( + invalidation.getObjectId(), "invalidate", invalidation.toString());    acknowledge(ackHandle);  } @@ -129,7 +129,8 @@  Log.i(TAG, "invalidateUnknownVersion: " + objectId);    // Do real work here based upon the invalidation. - MainActivity.State.setVersion(objectId, "Version from backend: " + getBackendVersion(objectId)); + MainActivity.State.setVersion( + objectId, "invalidateUnknownVersion", getBackendVersion(objectId));    acknowledge(ackHandle);  } @@ -140,8 +141,7 @@    // Do real work here based upon the invalidation.  for (ObjectId objectId : interestingObjects) { - MainActivity.State.setVersion(objectId, - "Version from backend: " + getBackendVersion(objectId)); + MainActivity.State.setVersion(objectId, "invalidateAll", getBackendVersion(objectId));  }    acknowledge(ackHandle); @@ -287,7 +287,7 @@  return getApplicationContext().getSharedPreferences(PREFERENCES_NAME, MODE_PRIVATE);  }   - private long getBackendVersion(ObjectId objectId) { + private String getBackendVersion(ObjectId objectId) {  /***********************************************************************************************  * YOUR CODE HERE  * @@ -298,7 +298,7 @@  // Normally, we would connect to a real application backend. For this example, we return a fixed  // value.   - return -1; + return "some value from custom app backend";  }    /** Gets object ID given index. */ 
diff --git a/src/java/com/google/ipc/invalidation/examples/android2/MainActivity.java b/src/java/com/google/ipc/invalidation/examples/android2/MainActivity.java index a6612a2..553eadc 100644 --- a/src/java/com/google/ipc/invalidation/examples/android2/MainActivity.java +++ b/src/java/com/google/ipc/invalidation/examples/android2/MainActivity.java 
@@ -35,13 +35,17 @@  * A simple sample application that displays information about object registrations and  * versions.  * - * <p>To submit invalidations, you can use the ExampleServlet, e.g.: + * <p>To submit invalidations, you can run the ExampleServlet:  *  * <p><code> - * blaze run -- //java/com/google/ipc/invalidation/examples:ExampleServlet --publisherSpec="" \ - --port=8888 --channelUri="talkgadget.google.com" --use_lcs=false + * blaze run java/com/google/ipc/invalidation/examples:ExampleServlet -- \ + --publisherSpec="" \ + --port=8888 \ + --channelUri="talkgadget.google.com"  * </code>  * + * <p>and open http://localhost:8888/publisher. + *  * <p>Just publish invalidations with ids similar to 'Obj1', 'Obj2', ... 'Obj3'  *  */ @@ -67,10 +71,13 @@  new HashMap<ObjectId, String>();  private static volatile MainActivity currentActivity;   - public static void setVersion(ObjectId objectId, String version) { + public static void setVersion(ObjectId objectId, String origin, String description) {  synchronized (lastInformedVersion) { - lastInformedVersion.put(objectId, version); + Log.i(TAG, "[setVersion] oid=" + objectId + + ", origin=" + origin + ", descript=" + description); + lastInformedVersion.put(objectId, "From " + origin + "; des=" + description);  } + Log.i(TAG, "[setVersion] calling refreshData");  refreshData();  }  } @@ -81,7 +88,7 @@  /** Called when the activity is first created. */  @Override  public void onCreate(Bundle savedInstanceState) { - Log.i(TAG, "Creating main activity"); + Log.i(TAG, "[onCreate] Creating main activity");  super.onCreate(savedInstanceState);    MultiplexingGcmListener.initializeGcm(this); @@ -99,6 +106,7 @@  // Remember the current activity since the TICL service in this example communicates via  // static state.  State.currentActivity = this; + Log.i(TAG, "[onCreate] Calling refresh data from main activity");  refreshData();  }   @@ -107,13 +115,15 @@  final MainActivity activity = State.currentActivity;  if (null != activity) {  final StringBuilder builder = new StringBuilder(); - builder.append("\nLast informed versions status\n---------------\n"); + builder.append("\nLast informed versions status\n"); + builder.append("--begin-------------\n");  synchronized (State.lastInformedVersion) {  for (Entry<ObjectId, String> entry : State.lastInformedVersion.entrySet()) {  builder.append(entry.getKey().toString()).append(" -> ").append(entry.getValue())  .append("\n");  }  } + builder.append("--end---------------\n");  activity.info.post(new Runnable() {  @Override  public void run() { 
diff --git a/src/java/com/google/ipc/invalidation/external/client/InvalidationClientFactory.java b/src/java/com/google/ipc/invalidation/external/client/InvalidationClientFactory.java index 9f88487..20c6615 100644 --- a/src/java/com/google/ipc/invalidation/external/client/InvalidationClientFactory.java +++ b/src/java/com/google/ipc/invalidation/external/client/InvalidationClientFactory.java 
@@ -44,24 +44,6 @@  return new InvalidationClientImpl(resources, random, clientConfig.clientType,  clientConfig.clientName, internalConfig, clientConfig.applicationName, listener);  } - /** - * Constructs an invalidation client library instance. - * Deprecated, please use {@link #createClient} instead. - * - * @param resources {@link SystemResources} to use for logging, scheduling, persistence, and - * network connectivity - * @param clientType client type code as assigned by the notification system's backend - * @param clientName id/name of the client in the application's own naming scheme - * @param applicationName name of the application using the library (for debugging/monitoring) - * @param listener callback object for invalidation events - */ - @Deprecated - public static InvalidationClient create(SystemResources resources, int clientType, - byte[] clientName, String applicationName, InvalidationListener listener) { - final InvalidationClientConfig appConfig = new InvalidationClientConfig(clientType, clientName, - applicationName, true /* allowSuppression */); - return createClient(resources, appConfig, listener); - }    private InvalidationClientFactory() {} // Prevents instantiation.  } 
diff --git a/src/java/com/google/ipc/invalidation/ticl/ProtocolHandler.java b/src/java/com/google/ipc/invalidation/ticl/ProtocolHandler.java index 6d36126..3c9e06e 100644 --- a/src/java/com/google/ipc/invalidation/ticl/ProtocolHandler.java +++ b/src/java/com/google/ipc/invalidation/ticl/ProtocolHandler.java 
@@ -654,7 +654,8 @@  ClientToServerMessage.Builder msgBuilder =  batcher.toBuilder(listener.getClientToken() != null);  if (msgBuilder == null) { - // Happens when we don't have a token and are not sending an initialize message. + // Happens when we don't have a token and are not sending an initialize message. Logged + // in batcher.toBuilder().  return;  }  msgBuilder.setHeader(createClientHeader()); @@ -669,6 +670,8 @@  }    statistics.recordSentMessage(SentMessageType.TOTAL); + logger.fine("Sending message to server: {0}", + CommonProtoStrings2.toLazyCompactString(message, true));  network.sendMessage(message.toByteArray());    // Record that the message was sent. We're invoking the listener directly, rather than 
diff --git a/src/java/com/google/ipc/invalidation/ticl/android2/AndroidInternalScheduler.java b/src/java/com/google/ipc/invalidation/ticl/android2/AndroidInternalScheduler.java index 5b4c5d8..55a8321 100644 --- a/src/java/com/google/ipc/invalidation/ticl/android2/AndroidInternalScheduler.java +++ b/src/java/com/google/ipc/invalidation/ticl/android2/AndroidInternalScheduler.java 
@@ -71,13 +71,13 @@    /**  * If {@code true}, {@link #isRunningOnThread} will verify that calls are being made from either - * the {@link TiclService} or the {@link TestTiclService.TestableClient}. + * the {@link TiclService} or the {@link TestableTiclService.TestableClient}.  */  public static boolean checkStackForTest = false;    /** Class name of the testable client class, for checking call stacks in tests. */  private static final String TESTABLE_CLIENT_CLASSNAME_FOR_TEST = - "com.google.ipc.invalidation.ticl.android2.TestTiclService$TestableClient"; + "com.google.ipc.invalidation.ticl.android2.TestableTiclService$TestableClient";    /**  * {@link RecurringTask}-created runnables that can be executed by this instance, by their names.